home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume10 / gb3 / patch2h < prev    next >
Encoding:
Internet Message Format  |  1990-08-28  |  58.9 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i046:  gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Patch2h
  5. Message-ID: <6233@tekred.CNA.TEK.COM>
  6. Date: 28 Aug 90 19:36:33 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2101
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: VANCLEEF@mps.ohio-state.edu
  12. Posting-number: Volume 11, Issue 46
  13. Archive-name: gb3/Patch2h
  14. Patch-To: gb3: Volume 10, Issue 1-14
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 8 (of 9)."
  25. # Contents:  client/cmd.c server/capture.c server/cs.c server/declare.c
  26. #   server/land.c server/launch.c server/scrap.c server/ships.h
  27. # Wrapped by billr@saab on Tue Aug 28 08:54:59 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'client/cmd.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Renaming existing file \"'client/cmd.c'\" to \"'client/cmd.c.orig'\"
  31.   mv -f 'client/cmd.c' 'client/cmd.c.orig'
  32. fi
  33. echo shar: Extracting \"'client/cmd.c'\" \(1462 characters\)
  34. sed "s/^X//" >'client/cmd.c' <<'END_OF_FILE'
  35. X/* cmd.c -- client commands.  so far, 'source <file>'
  36. X * copyright (C) Robert Chansky, 1990.  See the disclaimer in the GB server
  37. X * for copyright information.
  38. X */
  39. X
  40. X#include <string.h>
  41. X#include <stdio.h>
  42. X
  43. X/* return '1' if this was, in fact, a client-recognized command. */
  44. X
  45. Xint client_cmd(cmd)
  46. Xchar           *cmd;
  47. X{
  48. Xchar *c;
  49. X c=cmd;
  50. X while (*c!='\0' && *c!=' ' && *c!='\t') c++;    /* skip over command */
  51. X while (*c==' ' || *c=='\t') c++;    /* skip over ws */
  52. X
  53. X if (!strncmp(cmd, "source", strlen("source"))) {
  54. X    source(c);        /* the rest is the filename argument */
  55. X    return 1;
  56. X } else if (!strncmp(cmd, "script", strlen("script"))) {
  57. X    script(c);
  58. X    return 1;
  59. X } else
  60. X    return 0;
  61. X
  62. X}
  63. X
  64. X/* "script" (send output to) a file */
  65. Xscript(file)
  66. Xchar*  file;
  67. X{
  68. X
  69. X}
  70. X
  71. X
  72. X/* "source" the file, if the file exists. */
  73. X
  74. Xsource(file)
  75. Xchar  *file;
  76. X{
  77. XFILE *sourcefd;
  78. Xint c,i=0,j=1;
  79. Xchar sourcein[1024], *nn;
  80. X
  81. X if ((nn = rindex(file, '\n'))!=NULL)    /* remove '\n' from file name */
  82. X    *nn = '\0';
  83. X
  84. X if (file=='\0') {
  85. X    printf("usage: source <file>\n");
  86. X    return;
  87. X }
  88. X
  89. X if ((sourcefd = fopen(file, "r"))==NULL) {
  90. X    printf("error opening file '%s'\n",file);
  91. X    return;
  92. X }
  93. X
  94. X printf("sourceing file '%s'\n",file);
  95. X
  96. X /* get a line of input and send to GB */
  97. X do {
  98. X    do {
  99. X        c=fgetc(sourcefd);
  100. X        sourcein[i++] = c;
  101. X     } while (c != '\n' && c!=EOF);
  102. X    sourcein[i] = '\0'; sourcein[i+1] = '\0';
  103. X
  104. X    printf("%d: '%s'\n", j, sourcein);
  105. X    transmit(sourcein, i+1);
  106. X    i = 0;
  107. X    j++;
  108. X
  109. X } while (c!=EOF);
  110. X
  111. X fclose(sourcefd);
  112. X
  113. X}
  114. END_OF_FILE
  115. if test 1462 -ne `wc -c <'client/cmd.c'`; then
  116.     echo shar: \"'client/cmd.c'\" unpacked with wrong size!
  117. fi
  118. # end of 'client/cmd.c'
  119. if test -f 'server/capture.c' -a "${1}" != "-c" ; then 
  120.   echo shar: Renaming existing file \"'server/capture.c'\" to \"'server/capture.c.orig'\"
  121.   mv -f 'server/capture.c' 'server/capture.c.orig'
  122. fi
  123. echo shar: Extracting \"'server/capture.c'\" \(8187 characters\)
  124. sed "s/^X//" >'server/capture.c' <<'END_OF_FILE'
  125. X/*
  126. X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  127. X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  128. X** Restrictions in GB_copyright.h.
  129. X**
  130. X**  capture.c -- capture a ship on the ground
  131. X**
  132. X*/
  133. X
  134. X#include "GB_copyright.h"
  135. X#define EXTERN extern
  136. X#include "vars.h"
  137. X#include "ships.h"
  138. X#include "races.h"
  139. X#include "buffers.h"
  140. X#include <signal.h>
  141. X#include <math.h>
  142. X#include <signal.h>
  143. X
  144. Xint capture_sectdata,capture_shdata,capture_pdata, capture_racedata;
  145. X
  146. Xextern int Defensedata[];
  147. X
  148. X
  149. Xcapture(Playernum,APcount, argn,args)
  150. Xint Playernum;
  151. Xint APcount;
  152. Xint argn;
  153. Xchar args[MAXARGS][COMMANDSIZE];
  154. X{
  155. Xshiptype *ship;
  156. Xplanettype *p;
  157. Xsectortype *sect;
  158. Xboolean Land=0,Dock=0,cont,planetmod=0,sectmod=0;
  159. Xint boarders,olddpopn,oldapopn,oldowner,shipdam,booby,pris,
  160. X    numdest=0,shipno,x= -1,y= -1,i,mask, casualties, casualties2, casualty_scale;
  161. Xfloat astrength,dstrength;
  162. Xracetype *Race, *alien;
  163. X
  164. Xcapture_sectdata = capture_shdata = capture_pdata = NEUTRAL_FD;
  165. X
  166. Xsscanf(args[1]+(args[1][0]=='#'), "%d",&shipno);
  167. X
  168. X  openshdata(&capture_shdata);
  169. X  if (!getship(capture_shdata, &ship, shipno)) {
  170. X    sprintf(buf,"Ship doesn't exist.\n");
  171. X    notify(Playernum, buf);
  172. Xclose(capture_shdata);
  173. X    return;
  174. X  }
  175. Xclose(capture_shdata);
  176. X
  177. X  if (!ship->is_alive || !(ship->is_docked && ship->whatdest==LEVEL_PLAN) ) {
  178. X    sprintf(buf,"%s #%d is not landed on a planet.\n",
  179. X        Shipnames[ship->type], shipno);
  180. X    notify(Playernum, buf);
  181. X    free(ship);
  182. X    return;
  183. X  }
  184. X
  185. X  if (ship->owner==Playernum) {
  186. X    sprintf(buf,"That's your own ship.\n");
  187. X    notify(Playernum, buf);
  188. X    free(ship);
  189. X    return;
  190. X  }
  191. X
  192. X
  193. X  if (!enufAP(Playernum,Stars[ship->storbits]->AP[Playernum-1], APcount)) {
  194. X      free(ship);
  195. X      return;
  196. X    }
  197. X
  198. Xx = (int)ship->xpos;
  199. Xy = (int)ship->ypos;
  200. X
  201. X     openpdata(&capture_pdata);
  202. X     getplanet(capture_pdata, &p, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  203. X     close_file(capture_pdata);
  204. X
  205. X     opensectdata(&capture_sectdata);
  206. X     getsector(capture_sectdata,§,
  207. X     p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  208. X
  209. X     if (sect->owner!=Playernum) {
  210. X    sprintf(buf,"You don't own the sector where the ship is landed.\n");
  211. X    notify(Playernum, buf);
  212. X    free(sect);
  213. X    free(p);
  214. X    free(ship);
  215. X    return;
  216. X     }
  217. X
  218. Xif(argn<2)
  219. X    boarders = sect->popn;
  220. Xelse
  221. X    boarders = atoi(args[2]);
  222. X
  223. X        if (boarders > sect->popn || boarders <= 0) {
  224. X            sprintf(buf,"Illegal number of boarders (max can be %d).\n",
  225. X                sect->popn);
  226. X            notify(Playernum, buf);
  227. X            free(ship);
  228. X            free(sect);
  229. X            free(p);
  230. X            return;
  231. X        }
  232. X
  233. X    openracedata(&capture_racedata);
  234. X    getrace(capture_racedata, &Race, Playernum);
  235. X    close_file(capture_racedata);
  236. X
  237. X    openracedata(&capture_racedata);
  238. X         getrace(capture_racedata, &alien, (int)ship->owner);
  239. X    close_file(capture_racedata);
  240. X
  241. X     if (isset(Race->allied, ship->owner))
  242. X    {
  243. X    sprintf(buf,"Boarding the ship of your ally, %s\n", alien->name);
  244. X    notify(Playernum, buf);
  245. X    }
  246. X
  247. X     oldapopn = boarders;
  248. X     olddpopn = ship->popn;
  249. X     oldowner = ship->owner;
  250. X    shipdam = 0;
  251. X    casualties = 0;
  252. X    casualties2 = 0;
  253. X
  254. X    if(olddpopn || !Max_crew(ship)) {
  255. X
  256. X     sprintf(buf,"Attack strength: %.2f     Defense strength: %.2f\n",
  257. X           astrength = (float)boarders * (float)Race->fighters
  258. X                * .01 * Race->tech
  259. X                    * (Race->likes[sect->des] + 0.01)
  260. X            * ((sect->is_wasted ? 0.0 : (float)Defensedata[sect->des]) + 1.0),
  261. X
  262. X            dstrength = (Max_crew(ship) ? (float)ship->popn * (float)alien->fighters : 1)
  263. X                * .01 * alien->tech
  264. X             * ((float)Armor(ship) + 0.01)
  265. X                    * .01 * (100.0 - (float)ship->damage));
  266. X
  267. X    notify(Playernum, buf);
  268. X    sect->popn -= boarders;
  269. X    booby = 0;
  270. Xcasualty_scale = MIN(boarders, ship->popn + ship->destruct);
  271. X
  272. Xif(astrength > 0.0)
  273. X        casualties = int_rand(0, round_rand((float)casualty_scale * (dstrength+1.0) /
  274. X              (astrength+1.0)));
  275. X
  276. Xif(dstrength > 0.0) {
  277. X    casualties2 =  int_rand(0, round_rand((float)casualty_scale * (astrength+1.0) / 
  278. X            (dstrength+1.0)));
  279. X
  280. X         shipdam = int_rand(0,round_rand(25. * (astrength+1.0)/(dstrength+1.0)));
  281. X    ship->damage = MIN(100, ship->damage+shipdam);
  282. X
  283. X    if(!Max_crew(ship) && ship->destruct) {    /* booby trapped robot ships */
  284. X        casualties += int_rand(0, 10*ship->destruct);    
  285. X        booby = int_rand(0, 10*ship->destruct);
  286. X        booby = MIN(100, booby);
  287. X        shipdam += booby;
  288. X        ship->damage += booby;
  289. X    }
  290. X
  291. X
  292. X    if(ship->damage >= 100)
  293. X            kill_ship(Playernum, ship);
  294. X                        
  295. X    }
  296. X
  297. X         casualties = MIN(boarders, casualties);
  298. X    boarders -= casualties;
  299. X
  300. X    casualties2 = MIN(olddpopn, casualties2);
  301. X    ship->popn -= casualties2;
  302. X    ship->mass -= casualties2 * alien->mass;
  303. X
  304. X }
  305. X
  306. X           if (!ship->popn && ship->is_alive) {
  307. X                /* we got 'em */
  308. X            ship->owner = Playernum;
  309. X            ship->popn = MIN(boarders, Max_crew(ship));
  310. X            sect->popn += boarders - ship->popn;
  311. X                                 /* return excess boarders home */
  312. X            ship->mass += ship->popn * Race->mass;    /* our mass */
  313. X           } else {        /* retreat */
  314. X            sect->popn += boarders;
  315. X           }
  316. X
  317. X    if(!sect->popn)
  318. X        sect->owner = 0;
  319. X
  320. X        sprintf(buf,"BULLETIN from %s/%s!!\n",
  321. X            Stars[ship->storbits]->name,Stars[ship->storbits]->pnames[ship->pnumorbits]);
  322. X        notify(oldowner, telegram_buf);
  323. X        sprintf(buf,"You are being attacked by%s Player #%d (%s)!!!\n",
  324. X            (isset(alien->allied,Playernum) ? " your ally" :
  325. X                (isset(alien->atwar,Playernum) ? " your enemy" : " neutral")),
  326. X                Playernum,Race->name);
  327. X        notify(oldowner, buf);
  328. X        sprintf(buf,"%s #%d ASSAULTED at sector %d,%d [owner %d] !\n",
  329. X            Shipnames[ship->type], shipno, x, y, sect->owner);
  330. X        notify(oldowner, buf);
  331. X
  332. Xif(booby) {
  333. X     sprintf(buf,"Booby trap triggered causing %d%% damage.\n", booby);
  334. X        notify(oldowner, buf);
  335. X        notify(Playernum, buf);
  336. X}
  337. X
  338. Xif(shipdam) {
  339. X     sprintf(buf,"Total damage: %d%% (now %d%%)\n", shipdam, ship->damage);
  340. X        notify(oldowner, buf);
  341. X        sprintf(buf,"Damage inflicted:  Them: %d%% (now %d%%)\n",
  342. X            shipdam,ship->damage);
  343. X        notify(Playernum, buf);
  344. X }
  345. X
  346. X     if(!ship->is_alive) {
  347. X          sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
  348. X        notify(oldowner, buf);
  349. X          sprintf(buf,"              Their ship DESTROYED!!!\n");
  350. X        notify(Playernum, buf);
  351. X    }
  352. X
  353. X            if (ship->owner==Playernum) {
  354. X                sprintf(buf,"%s CAPTURED!\n",Shipnames[ship->type]);
  355. X                    notify(oldowner, buf);
  356. X                sprintf(buf,"VICTORY! The ship is yours!\n");
  357. X                    notify(Playernum, buf);
  358. X                 if ((astrength+1.0)/(dstrength+1.0) > 5.0 && olddpopn) {
  359. X                   pris=astrength/dstrength;
  360. X                   pris=MIN(pris,olddpopn);
  361. X                if (Race->captured_prisoners[oldowner-1]<100) {
  362. X                     Race->captured_prisoners[oldowner-1] +=
  363. X                     pris;
  364. X                   sprintf(buf,"%d prisoner%s captured!\n",
  365. X                       pris, ((pris>1) ? "s" : ""));
  366. X                    notify(Playernum, buf);
  367. X                    notify(oldowner, buf);
  368. X                 }
  369. X                   }
  370. X
  371. X                if (ship->popn)
  372. X                    {
  373. X                  sprintf(buf,"%d boarders move in.\n",
  374. X                      MIN(boarders, ship->popn));
  375. X                      notify(Playernum, buf);
  376. X                    }
  377. X            } else if(ship->popn) {
  378. X                sprintf(buf,"You fought them off!\n");
  379. X                    notify(oldowner, buf);
  380. X                sprintf(buf,"The boarding was repulsed; try again.\n");
  381. X                    notify(Playernum, buf);
  382. X            }
  383. X
  384. X        if (ship->is_alive) {
  385. X            if (sect->popn + boarders == 0) {
  386. X                sprintf(buf,"You killed all the aliens in this sector!\n");
  387. X                    notify(oldowner, buf);
  388. X            } else sprintf(buf," ");
  389. X            if (boarders==0) {
  390. X                sprintf(buf,"Oh no! They killed your party to the last man!\n");
  391. X                    notify(Playernum, buf);
  392. X            }
  393. X        } else {
  394. X            sprintf(buf,"Your ship was weakened too much!\n");
  395. X                    notify(oldowner, buf);
  396. X            sprintf(buf,"The assault weakened their ship too much!\n");
  397. X                    notify(Playernum, buf);
  398. X        }
  399. X
  400. Xif(casualties || casualties2) {
  401. Xsprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties2, casualties);
  402. X                notify(oldowner, buf);
  403. X        sprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties, casualties2);
  404. X                notify(Playernum, buf);
  405. X}
  406. X     openshdata(&capture_shdata);
  407. X     putship(capture_shdata, ship, shipno);
  408. X     close_file(capture_shdata);
  409. X
  410. X     putsector(capture_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  411. X     close_file(capture_sectdata);
  412. X
  413. X     deductAPs(Playernum, APcount, ship->storbits, 0);
  414. X
  415. X    openracedata(&capture_racedata);
  416. X        putrace(capture_racedata, Race);
  417. X    close_file(capture_racedata);
  418. X
  419. X
  420. X         free(alien);
  421. X    free(Race);
  422. X    free(p);
  423. X         free(ship);
  424. X         free(sect);
  425. X
  426. X}
  427. X
  428. END_OF_FILE
  429. if test 8187 -ne `wc -c <'server/capture.c'`; then
  430.     echo shar: \"'server/capture.c'\" unpacked with wrong size!
  431. fi
  432. # end of 'server/capture.c'
  433. if test -f 'server/cs.c' -a "${1}" != "-c" ; then 
  434.   echo shar: Renaming existing file \"'server/cs.c'\" to \"'server/cs.c.orig'\"
  435.   mv -f 'server/cs.c' 'server/cs.c.orig'
  436. fi
  437. echo shar: Extracting \"'server/cs.c'\" \(6810 characters\)
  438. sed "s/^X//" >'server/cs.c' <<'END_OF_FILE'
  439. X/*
  440. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  441. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  442. X * Restrictions in GB_copyright.h.
  443. X *  cs.c -- change scope (directory)
  444. X */
  445. X
  446. X#include "GB_copyright.h"
  447. X#define EXTERN extern
  448. X#include "vars.h"
  449. X#include "ships.h"
  450. X#include "races.h"
  451. X#include "buffers.h"
  452. Xint cs_racedata, cs_shdata;
  453. X
  454. Xcenter(Playernum, APcount, argn, args)
  455. Xint Playernum;
  456. Xint APcount;
  457. Xint argn;
  458. Xchar args[MAXARGS][COMMANDSIZE];
  459. X{
  460. Xplacetype where;
  461. X
  462. X  where = Getplace(Playernum,args[1],1);    
  463. X
  464. X  if (where.err) {
  465. X    sprintf(buf,"cs: bad scope.\n");
  466. X        notify(Playernum, buf);
  467. X    return;
  468. X  }
  469. X
  470. XDir[Playernum-1].lastx[1] = Stars[where.snum]->xpos;
  471. XDir[Playernum-1].lasty[1] = Stars[where.snum]->ypos;
  472. X
  473. X}
  474. X
  475. Xdo_prompt(r)
  476. Xracetype *r;
  477. X{
  478. Xshiptype *s;
  479. Xint Playernum;
  480. X
  481. XPlayernum = r->Playernum;
  482. X
  483. X    if(Dir[Playernum-1].level==LEVEL_UNIV) {
  484. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] / )\n",
  485. X        r->weekly/60, r->daily/60,
  486. X        Sdata.AP[Playernum-1]);
  487. X    } else if(Dir[Playernum-1].level==LEVEL_STAR) {
  488. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s )\n",
  489. X        r->weekly/60, r->daily/60,
  490. X        Stars[Dir[Playernum-1].snum]->AP[Playernum-1],
  491. X        Stars[Dir[Playernum-1].snum]->name);
  492. X    } else if(Dir[Playernum-1].level==LEVEL_PLAN) {
  493. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s/%s )\n",
  494. X        r->weekly/60, r->daily/60,
  495. X        Stars[Dir[Playernum-1].snum]->AP[Playernum-1],
  496. X        Stars[Dir[Playernum-1].snum]->name,
  497. X        Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum]);
  498. X    } else if(Dir[Playernum-1].level==LEVEL_SHIP) {
  499. X    openshdata(&cs_shdata);
  500. X    getship(cs_shdata, &s, Dir[Playernum-1].shipno);
  501. X    switch(s->whatorbits) {
  502. X        case LEVEL_UNIV :
  503. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /  #%d)\n",
  504. X        r->weekly/60, r->daily/60, Sdata.AP[Playernum-1],
  505. X        Dir[Playernum-1].shipno);
  506. X            break;
  507. X        case LEVEL_STAR :
  508. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s #%d)\n",
  509. X        r->weekly/60, r->daily/60,
  510. X        Stars[s->storbits]->AP[Playernum-1],
  511. X        Stars[s->storbits]->name,
  512. X        Dir[Playernum-1].shipno);
  513. X        break;
  514. X        case LEVEL_PLAN :
  515. X    sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s/%s #%d)\n",
  516. X        r->weekly/60, r->daily/60,
  517. X        Stars[s->storbits]->AP[Playernum-1],
  518. X        Stars[s->storbits]->name,
  519. X        Stars[s->storbits]->pnames[Dir[Playernum-1].pnum],
  520. X        Dir[Playernum-1].shipno);
  521. X        break;
  522. X          default :
  523. X          break;
  524. X    }
  525. X    close_file(cs_shdata);
  526. X    free(s);
  527. X    }
  528. X}
  529. X
  530. Xcs(Playernum, APcount, argn,args)
  531. Xint Playernum;
  532. Xint APcount;
  533. Xint argn;
  534. Xchar args[MAXARGS][COMMANDSIZE];
  535. X{
  536. X placetype where;
  537. X planettype *planet;
  538. X shiptype *s;
  539. X int cs_shdata,cs_pdata;
  540. X racetype *Race;
  541. Xopenracedata(&cs_racedata);
  542. Xgetrace(cs_racedata, &Race, Playernum); 
  543. Xclose_file(cs_racedata);
  544. X
  545. Xif (argn==1) {
  546. X    /* chdir to def scope */
  547. X  Dir[Playernum-1].level = Race->deflevel;
  548. X  if ((Dir[Playernum-1].snum = Race->defsystem) >= Sdata.numstars)
  549. X    Dir[Playernum-1].snum = Sdata.numstars-1;
  550. X  if ((Dir[Playernum-1].pnum = Race->defplanetnum) >= Stars[Dir[Playernum-1].snum]->numplanets)
  551. X  Dir[Playernum-1].pnum = Stars[Dir[Playernum-1].snum]->numplanets-1;
  552. X  Dir[Playernum-1].shipno = 0;
  553. X  Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  554. X  Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos;
  555. X  Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos;
  556. X  free(Race);
  557. X  return;
  558. X } else if (argn==2) {
  559. X    /* chdir to specified scope */
  560. X
  561. X  where = Getplace(Playernum,args[1],0);    /* do not ignore the fact that you've not
  562. X                    explored the place */
  563. X  if (where.err) {
  564. X    sprintf(buf,"cs: bad scope.\n");
  565. X        notify(Playernum, buf);
  566. X    Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  567. X    free(Race);
  568. X    return;
  569. X  }
  570. X
  571. X    /* fix lastx, lasty coordinates */
  572. X
  573. X  switch (Dir[Playernum-1].level) {
  574. X
  575. X    case LEVEL_UNIV:
  576. X        Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  577. X        break;
  578. X
  579. X    case LEVEL_STAR:
  580. X        if (where.level==LEVEL_UNIV) {
  581. X            Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos;
  582. X            Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos;
  583. X        } else
  584. X            Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  585. X        break;
  586. X
  587. X    case LEVEL_PLAN:
  588. X        openpdata(&cs_pdata);
  589. X        getplanet(cs_pdata,&planet,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
  590. X        close_file(cs_pdata);
  591. X        if (where.level==LEVEL_STAR && where.snum==Dir[Playernum-1].snum) {
  592. X            Dir[Playernum-1].lastx[0] = planet->xpos;
  593. X            Dir[Playernum-1].lasty[0] = planet->ypos;
  594. X        } else if (where.level==LEVEL_UNIV) {
  595. X            Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos + planet->xpos;
  596. X            Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos + planet->ypos;
  597. X        } else
  598. X            Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  599. X        free(planet);
  600. X        break;
  601. X    case LEVEL_SHIP:
  602. X        openshdata(&cs_shdata);
  603. X        getship(cs_shdata, &s, Dir[Playernum-1].shipno);
  604. X        close_file(cs_shdata);
  605. X        if (!s->is_docked) {
  606. X         switch (where.level) {
  607. X           case LEVEL_UNIV:
  608. X            Dir[Playernum-1].lastx[1] = s->xpos;
  609. X            Dir[Playernum-1].lasty[1] = s->ypos;
  610. X            break;
  611. X           case LEVEL_STAR:
  612. X            if (s->whatorbits>=LEVEL_STAR && s->storbits==where.snum) {
  613. X                /* we are going UP from the ship.. change last*/
  614. X                Dir[Playernum-1].lastx[0] = s->xpos - Stars[s->storbits]->xpos;
  615. X                Dir[Playernum-1].lasty[0] = s->ypos - Stars[s->storbits]->ypos;
  616. X            } else
  617. X                Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  618. X            break;
  619. X           case LEVEL_PLAN:
  620. X            if (s->whatorbits==LEVEL_PLAN && s->storbits==where.snum
  621. X                   && s->pnumorbits==where.pnum) {
  622. X                /* same */
  623. X                openpdata(&cs_pdata);
  624. X                getplanet(cs_pdata,&planet,Stars[s->storbits]->planetpos[s->pnumorbits]);
  625. X                close_file(cs_pdata);
  626. X                Dir[Playernum-1].lastx[0] = s->xpos - Stars[s->storbits]->xpos - planet->xpos;
  627. X                Dir[Playernum-1].lasty[0] = s->ypos - Stars[s->storbits]->ypos - planet->ypos;
  628. X                free(planet);
  629. X            } else
  630. X                Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  631. X            break;
  632. X           case LEVEL_SHIP:
  633. X            Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  634. X            break;
  635. X           default:
  636. X            break;
  637. X            }
  638. X        } else
  639. X            Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
  640. X        free(s);
  641. X        break;
  642. X    default:
  643. X        break;
  644. X  }
  645. X
  646. X  Dir[Playernum-1].level = where.level;
  647. X  Dir[Playernum-1].snum = where.snum;
  648. X  Dir[Playernum-1].pnum = where.pnum;
  649. X  Dir[Playernum-1].shipno = where.shipno;
  650. X
  651. X
  652. X } else if (argn==3 && args[1][1]=='d') {
  653. X    /* make new def scope */
  654. X  where = Getplace(Playernum,args[2],0);
  655. X  if (!where.err) {
  656. X    Race->deflevel = where.level;
  657. X    Race->defsystem = where.snum;
  658. X    Race->defplanetnum = where.pnum;
  659. X    openracedata(&cs_racedata);
  660. X        putrace(cs_racedata, Race);
  661. X    close_file(cs_racedata);
  662. X
  663. X    sprintf(buf,"New home system is %s\n",Dispplace(Playernum, &where));
  664. X  } else {
  665. X    sprintf(buf,"cs: bad home system.\n");
  666. X    free(Race);
  667. X    return;
  668. X  }
  669. X}
  670. X free(Race);
  671. X}
  672. X
  673. END_OF_FILE
  674. if test 6810 -ne `wc -c <'server/cs.c'`; then
  675.     echo shar: \"'server/cs.c'\" unpacked with wrong size!
  676. fi
  677. # end of 'server/cs.c'
  678. if test -f 'server/declare.c' -a "${1}" != "-c" ; then 
  679.   echo shar: Renaming existing file \"'server/declare.c'\" to \"'server/declare.c.orig'\"
  680.   mv -f 'server/declare.c' 'server/declare.c.orig'
  681. fi
  682. echo shar: Extracting \"'server/declare.c'\" \(8063 characters\)
  683. sed "s/^X//" >'server/declare.c' <<'END_OF_FILE'
  684. X/* 
  685. X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  686. X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  687. X** Restrictions in GB_copyright.h.
  688. X** declare.c -- declare alliance, neutrality, war, the basic thing.
  689. X*/
  690. X
  691. X#include "GB_copyright.h"
  692. X#define EXTERN extern
  693. X#include "vars.h"
  694. X#include "races.h"
  695. X#include "buffers.h"
  696. X#include <signal.h>
  697. X#include <ctype.h>
  698. Xint declare_racedata, i;
  699. X
  700. X/* invite people to join your alliance block */
  701. Xinvite(Playernum, APcount, argn, args, mode)
  702. Xint Playernum;
  703. Xint APcount;
  704. Xint argn;
  705. Xchar args[MAXARGS][COMMANDSIZE];
  706. Xint mode;
  707. X{
  708. Xint n;
  709. Xracetype *Race, *alien;
  710. X
  711. XGetPlayer(args[1], &n, &alien);
  712. X   if (n < 1 || n > Numraces() ) {
  713. X    sprintf(buf,"No such player.\n");
  714. X        notify(Playernum, buf);
  715. X    return;
  716. X   }
  717. X
  718. Xif(n==Playernum) {
  719. X    notify(Playernum, "Not needed, you are the leader.\n");
  720. X    free(alien);
  721. X    return;
  722. X    }
  723. X
  724. X  openracedata(&declare_racedata); 
  725. X  getrace(declare_racedata, &Race, Playernum);    
  726. X  close_file(declare_racedata);
  727. X
  728. Xif(mode) {
  729. X    setbit(Blocks[Playernum-1].invite, n);
  730. X    sprintf(buf, "%s [%d] has invited you to join %s\n", Race->name, 
  731. X            Playernum, Blocks[Playernum-1].name);
  732. X    if(!notify(n, buf))
  733. X    push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  734. X    sprintf(buf, "%s [%d] has been invited to join %s [%d]\n",
  735. X        alien->name, n, Blocks[Playernum-1].name, Playernum);
  736. X    notify(Playernum, buf);
  737. X    } else {
  738. X    clrbit(Blocks[Playernum-1].invite, n);
  739. X
  740. X    sprintf(buf, "You have been blackballed from %s [%d]\n",
  741. X        Blocks[Playernum-1].name, Playernum);
  742. X    if(!notify(n, buf))
  743. X    push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  744. X
  745. X    sprintf(buf, "%s [%d] has been blackballed from %s [%d]\n",
  746. X        alien->name, n, Blocks[Playernum-1].name, Playernum);
  747. X    notify(Playernum, buf);
  748. X    }
  749. X    for(i=1; i<=Numraces(); i++)
  750. X        push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
  751. X
  752. XPutblock(Blocks);
  753. Xfree(Race);
  754. Xfree(alien);
  755. X}
  756. X
  757. X/* declare that you wish to be included in the alliance block */
  758. Xpledge(Playernum, APcount, argn, args, mode)
  759. Xint Playernum;
  760. Xint APcount;
  761. Xint argn;
  762. Xchar args[MAXARGS][COMMANDSIZE];
  763. Xint mode;
  764. X{
  765. Xint n;
  766. Xracetype *alien, *Race;
  767. X
  768. XGetPlayer(args[1], &n, &alien);
  769. X   if (n < 1 || n > Numraces() ) {
  770. X    sprintf(buf,"No such player.\n");
  771. X        notify(Playernum, buf);
  772. X    return;
  773. X   }
  774. X
  775. Xif(n==Playernum) {
  776. X    notify(Playernum, "Not needed, you are the leader.\n");
  777. X    free(alien);
  778. X    return;
  779. X    }
  780. X
  781. X  openracedata(&declare_racedata); 
  782. X  getrace(declare_racedata, &Race, Playernum);    
  783. X  close_file(declare_racedata);
  784. X
  785. X if(mode) {
  786. X    setbit(Blocks[n-1].pledge, Playernum);
  787. X    sprintf(buf, "%s [%d] has pledged %s.\n", Race->name, 
  788. X            Playernum, Blocks[n-1].name);
  789. X    if(!notify(n, buf))
  790. X    push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  791. X    sprintf(buf, "You have pledged allegiance to %s.\n",
  792. X                  Blocks[n-1].name);
  793. X    notify(Playernum, buf);
  794. X
  795. X    switch(int_rand(1,20)) {
  796. X      case 1:
  797. X        sprintf(buf, "%s [%d] joins the band wagon and pledges allegiance to %s [%d]!\n",
  798. X            Race->name, Playernum, Blocks[n-1].name, n);
  799. X        break;
  800. X      default:
  801. X        sprintf(buf, "%s [%d] pledges allegiance to %s [%d].\n",
  802. X            Race->name, Playernum, Blocks[n-1].name, n);
  803. X        break;
  804. X    }
  805. X
  806. X    } else {
  807. X    clrbit(Blocks[n-1].pledge, Playernum);
  808. X    sprintf(buf, "%s [%d] has quit %s [%d].\n", Race->name,
  809. X            Playernum, Blocks[n-1].name, n);
  810. X    if(!notify(n, buf))
  811. X    push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  812. X    sprintf(buf, "You have quit %s\n", Blocks[n-1].name);
  813. X    notify(Playernum, buf);
  814. X
  815. X    switch(int_rand(1,20)) {
  816. X      case 1:
  817. X        sprintf(buf, "%s [%d] calls %s [%d] a bunch of geeks and QUITS %s [%d]!\n",
  818. X            Race->name, Playernum, Blocks[n-1].name, n);
  819. X      default:
  820. X        sprintf(buf, "%s [%d] has QUIT %s [%d]!\n",
  821. X         Race->name, Playernum, Blocks[n-1].name, n);   
  822. X        break;
  823. X    }
  824. X    }
  825. X
  826. X    for(i=1; i<=Numraces(); i++)
  827. X        push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
  828. X    
  829. X
  830. Xcompute_power_blocks();
  831. Xfree(alien);
  832. Xfree(Race);
  833. XPutblock(Blocks);
  834. X}
  835. X
  836. Xdeclare(Playernum,APcount, argn,args)
  837. Xint Playernum;
  838. Xint APcount;
  839. Xint argn;
  840. Xchar args[MAXARGS][COMMANDSIZE];
  841. X{
  842. Xchar str[RNAMESIZE];
  843. Xint n;
  844. Xracetype *Race, *alien;
  845. X
  846. X     /* look in sdata for APs first */
  847. X   if (Sdata.AP[Playernum] >= APcount)  /* enufAPs would print something */
  848. X       deductAPs(Playernum,APcount, 0, 1);
  849. X     /* otherwise use current star */
  850. X   else if (Dir[Playernum-1].level==LEVEL_STAR || Dir[Playernum-1].level==LEVEL_PLAN) {
  851. X       if (enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount) )
  852. X       deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  853. X   } else {
  854. X       sprintf(buf,"You don't have enough AP's (%d)\n",APcount);
  855. X        notify(Playernum, buf);
  856. X    return;
  857. X   }
  858. X
  859. X   GetPlayer(args[1], &n, &alien);
  860. X   if (n < 1 || n > Numraces() ) {
  861. X    sprintf(buf,"No such player.\n");
  862. X        notify(Playernum, buf);
  863. X    return;
  864. X   }
  865. X
  866. X    openracedata(&declare_racedata); 
  867. X         getrace(declare_racedata, &Race, Playernum);    
  868. X    close_file(declare_racedata);
  869. X
  870. Xif(Race->Playernum != Playernum) {
  871. X    notify(Playernum, "Illegal race number - report to deity.\n");
  872. X    sprintf(buf, "Declare race number error %d != %d\n",
  873. X        Race->Playernum, Playernum);
  874. X    free(Race);
  875. X    free(alien);
  876. X    return;
  877. X}
  878. X
  879. X   switch (*args[2]) {
  880. X    case 'a':
  881. X        setbit(Race->allied, n);
  882. X        clrbit(Race->atwar, n);
  883. X        if (int_rand(0,100) >= 96)
  884. X            {
  885. X            sprintf(buf,"But would you want your sister to marry one?\n");
  886. X                notify(Playernum, buf);
  887. X        } else {
  888. X            sprintf(buf,"Good for you.\n");
  889. X                notify(Playernum, buf);
  890. X            }
  891. X
  892. X        sprintf(buf," Player #%d (%s) has declared an alliance with you!\n",
  893. X            Playernum,Race->name);
  894. X            if(!notify(n, buf))
  895. X        push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  896. X
  897. X        switch(int_rand(1,20)) {
  898. X          case 1:
  899. X            sprintf(buf, "%s [%d] sucks up to %s [%d] and declares an ALLIANCE!\n",
  900. X                Race->name, Playernum, alien->name, n);
  901. X            break;
  902. X          default:
  903. X            sprintf(buf, "%s [%d] declares an ALLIANCE with %s [%d].\n",
  904. X                Race->name, Playernum, alien->name, n);
  905. X            break;
  906. X        }
  907. X
  908. X        break;
  909. X    case 'n':
  910. X        clrbit(Race->allied, n);
  911. X        clrbit(Race->atwar, n);
  912. X        sprintf(buf,"Done.\n");
  913. X            notify(Playernum, buf);
  914. X
  915. X        sprintf(buf," Player #%d (%s) has declared neutrality with you!\n",Playernum,Race->name);
  916. X            if(!notify(n, buf))
  917. X        push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  918. X
  919. X        sprintf(buf, "%s [%d] declares a state of neutrality with %s [%d].\n",
  920. X            Race->name, Playernum, alien->name, n);
  921. X
  922. X        break;
  923. X    case 'w':
  924. X        setbit(Race->atwar, n);
  925. X        clrbit(Race->allied, n);
  926. X        if (int_rand(0,100) >= 96) {
  927. X            sprintf(buf, "Your enemies flaunt their secondary male reproductive glands in your\ngeneral direction.\n");
  928. X                notify(Playernum, buf);
  929. X        } else {
  930. X            sprintf(buf, "Give 'em hell!\n");
  931. X                notify(Playernum, buf);
  932. X            }
  933. X
  934. X        sprintf(buf," Player #%d (%s) has declared war against you!\n",Playernum,Race->name);
  935. X            if(!notify(n, buf))
  936. X        push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
  937. X
  938. X        switch(int_rand(1,5)) {
  939. X          case 1:
  940. X            sprintf(buf, "%s [%d] declares WAR on %s [%d].\n",
  941. X                Race->name, Playernum, alien->name, n);
  942. X            break;
  943. X          case 2:
  944. X            sprintf(buf, "%s [%d] has had enough of %s [%d] and declares WAR!\n",
  945. X                Race->name, Playernum, alien->name, n);
  946. X            break;
  947. X          case 3:
  948. X            sprintf(buf, "%s [%d] decided that it is time to declare WAR on %s [%d]!\n",
  949. X                Race->name, Playernum, alien->name, n);
  950. X            break;
  951. X          case 4:
  952. X            sprintf(buf, "%s [%d] had no choice but to declare WAR against %s [%d]!\n",
  953. X                Race->name, Playernum, alien->name, n);
  954. X            break;
  955. X          case 5:
  956. X            sprintf(buf, "%s [%d] says 'screw it!' and declares WAR on %s [%d]!\n",
  957. X                Race->name, Playernum, alien->name, n);
  958. X            break;
  959. X        default:
  960. X            break;
  961. X        }
  962. X        
  963. X        break;
  964. X    default:
  965. X        notify(Playernum, "I don't understand.\n");
  966. X        free(Race);
  967. X        free(alien);
  968. X        return;
  969. X        break;
  970. X   }
  971. X
  972. X        for(i=1; i<=Numraces(); i++)
  973. X            push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
  974. X
  975. X        
  976. X/* They, of course, learn more about you */
  977. Xalien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+30, 100);
  978. X
  979. Xopenracedata(&declare_racedata);
  980. Xputrace(declare_racedata, alien);
  981. Xputrace(declare_racedata, Race);
  982. Xclose_file(declare_racedata);
  983. Xfree(Race);
  984. Xfree(alien);
  985. X}
  986. X
  987. X
  988. END_OF_FILE
  989. if test 8063 -ne `wc -c <'server/declare.c'`; then
  990.     echo shar: \"'server/declare.c'\" unpacked with wrong size!
  991. fi
  992. # end of 'server/declare.c'
  993. if test -f 'server/land.c' -a "${1}" != "-c" ; then 
  994.   echo shar: Renaming existing file \"'server/land.c'\" to \"'server/land.c.orig'\"
  995.   mv -f 'server/land.c' 'server/land.c.orig'
  996. fi
  997. echo shar: Extracting \"'server/land.c'\" \(6431 characters\)
  998. sed "s/^X//" >'server/land.c' <<'END_OF_FILE'
  999. X/*
  1000. X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1001. X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1002. X** Restrictions in GB_copyright.h.
  1003. X**
  1004. X**  land.c -- land a ship
  1005. X**  also.... dock -- dock a ship w/ another ship 
  1006. X**  and..... assault -- a very un-PC version of land/dock
  1007. X*/
  1008. X
  1009. X#include "GB_copyright.h"
  1010. X#define EXTERN extern
  1011. X#include "vars.h"
  1012. X#include "ships.h"
  1013. X#include "races.h"
  1014. X#include "buffers.h"
  1015. X#include <signal.h>
  1016. X#include <math.h>
  1017. X
  1018. Xint land_sectdata,land_shdata,land_pdata, land_racedata;
  1019. Xint land_stdata;
  1020. X
  1021. Xland(Playernum,APcount, argn,args)
  1022. Xint Playernum;
  1023. Xint APcount;
  1024. Xint argn;
  1025. Xchar args[MAXARGS][COMMANDSIZE];
  1026. X{
  1027. Xchar c;
  1028. Xshiptype *s;
  1029. Xplanettype *p;
  1030. Xsectortype *sect;
  1031. Xplacetype where;
  1032. Xint shipno,x= -1,y= -1,i, numdest;
  1033. Xfloat fuel;
  1034. Xdouble Dist;
  1035. Xracetype *Race, *alien;
  1036. X
  1037. Xland_sectdata = land_shdata = land_pdata = NEUTRAL_FD;
  1038. X
  1039. X
  1040. X    sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  1041. X
  1042. X
  1043. X openshdata(&land_shdata);
  1044. X  if (!getship(land_shdata, &s, shipno)) {
  1045. X      notify(Playernum, "The ship wasn't found.\n");
  1046. X    close_file(land_shdata);
  1047. X    return;
  1048. X  }
  1049. Xclose_file(land_shdata);
  1050. X
  1051. X  if (testship(Playernum,s, shipno)) {
  1052. X      notify(Playernum, "Illegal format.\n");
  1053. X      free(s);
  1054. X      return;
  1055. X    }
  1056. X
  1057. X  if (s->is_docked) {
  1058. X    sprintf(buf,"Ship #%d is docked.\n",shipno);
  1059. X        notify(Playernum, buf);
  1060. X    free(s);
  1061. X    return;
  1062. X  }
  1063. X
  1064. X
  1065. X    sscanf(args[2],"%d,%d",&x,&y); /* landing on a sector */
  1066. X
  1067. X     if (s->whatorbits!=LEVEL_PLAN) {
  1068. X        sprintf(buf,"%s #%d doesn't orbit a planet.\n", Shipnames[s->type],
  1069. X            shipno);
  1070. X            notify(Playernum, buf);
  1071. X            free(s);
  1072. X            return;
  1073. X                 }
  1074. X
  1075. X      if (!Shipdata[s->type][ABIL_CANLAND]) {
  1076. X        sprintf(buf,"This ship is not equipped to land.\n");
  1077. X        notify(Playernum, buf);
  1078. X        free(s);
  1079. X        return;
  1080. X      }
  1081. X
  1082. X    if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum) {
  1083. X    sprintf(buf,"You have to cs to the planet it orbits.\n");
  1084. X        notify(Playernum, buf);
  1085. X    free(s);
  1086. X    return;
  1087. X    }
  1088. X
  1089. Xif (!speed_rating(s)) {
  1090. X        sprintf(buf,"This ship is not rated for maneuvering.\n");
  1091. X        notify(Playernum, buf);
  1092. X        free(s);
  1093. X        return;
  1094. X      }
  1095. X      
  1096. X    if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) { 
  1097. X     free(s);
  1098. X     return;
  1099. X    }
  1100. X
  1101. X     openpdata(&land_pdata);
  1102. X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  1103. X     close_file(land_pdata);
  1104. X     
  1105. X     sprintf(buf,"Planet /%s/%s has gravity field of %.2f.\n", Stars[s->storbits]->name,
  1106. X    Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
  1107. X        notify(Playernum, buf);
  1108. X
  1109. X     sprintf(buf,"Distance to planet: %.2f.\n",
  1110. X      Dist = sqrt((double)Distsq(Stars[s->storbits]->xpos + p->xpos, 
  1111. X                Stars[s->storbits]->ypos + p->ypos, 
  1112. X                s->xpos, s->ypos ) ) );
  1113. X        notify(Playernum, buf);
  1114. X
  1115. X     if (Dist > DIST_TO_LAND) {
  1116. X        sprintf(buf,"Ship #%d must be %.3g or closer to the planet (%.2f).\n",shipno, DIST_TO_LAND, Dist);
  1117. X        notify(Playernum, buf);
  1118. X    free(s);
  1119. X    free(p);
  1120. X    return;
  1121. X     }
  1122. X
  1123. X     fuel = 0.05 + .05*s->mass*gravity(p) * LAND_GRAV_MASS_FACTOR;
  1124. X
  1125. X    if (s->resource > Max_resource(s) || s->fuel > Max_fuel(s)
  1126. X        || s->popn > Max_crew(s) || s->destruct > Max_destruct(s)) {
  1127. X        sprintf(buf,"Ship is too overloaded to land.\n");
  1128. X        notify(Playernum, buf);
  1129. X        free(s);
  1130. X        free(p);
  1131. X        return;
  1132. X      }
  1133. X
  1134. X    if(x < 0 || y < 0 || x > p->Maxx || y > p->Maxy) {
  1135. X        sprintf(buf,"Illegal coordinates.\n");
  1136. X            notify(Playernum, buf);
  1137. X        free(s);
  1138. X        free(p);
  1139. X        return;
  1140. X            }
  1141. X
  1142. X    opensectdata(&land_sectdata);
  1143. X    getsector(land_sectdata,§,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  1144. X    close_file(land_sectdata);
  1145. X
  1146. X       if(s->type != OTYPE_TERRA) {
  1147. X        openracedata(&land_racedata);
  1148. X        getrace(land_racedata, &Race, Playernum); 
  1149. X        close_file(land_racedata);
  1150. X       if (Race->likes[sect->des] == 0.0 && !sect->is_wasted) {
  1151. X    sprintf(buf,"The ship is not built to land on that sector.\n");
  1152. X        notify(Playernum, buf);
  1153. X    free(Race);
  1154. X    free(s);
  1155. X    free(p);
  1156. X    free(sect);
  1157. X    return;
  1158. X               }
  1159. X    } 
  1160. X
  1161. X       if (sect->is_wasted) {
  1162. X    sprintf(buf,"Warning: That sector is a wasteland!\n");
  1163. X        notify(Playernum, buf);
  1164. X       } else if (sect->owner && sect->owner!=Playernum) {
  1165. X        openracedata(&land_racedata);
  1166. X        getrace(land_racedata, &Race, Playernum); 
  1167. X         getrace(land_racedata, &alien, (int)sect->owner);
  1168. X        close_file(land_racedata);
  1169. X
  1170. X       if(!(isset(Race->allied, sect->owner) && isset(alien->allied, Playernum))) {
  1171. X    sprintf(buf,"You are not mutually allied with %s.\n", alien->name);
  1172. X        notify(Playernum, buf);
  1173. X    free(Race);
  1174. X    free(alien);
  1175. X    free(sect);
  1176. X    free(p);
  1177. X    free(s);
  1178. X    return;
  1179. X      } else {
  1180. X    sprintf(buf,"You have landed on allied sector (%s).\n",alien->name);
  1181. X        notify(Playernum, buf);
  1182. X    }
  1183. X    free(alien);
  1184. X    free(Race);
  1185. X        }
  1186. X
  1187. X     if (s->fuel < fuel) {
  1188. X
  1189. X    kill_ship(s->owner, s);
  1190. X
  1191. X      where.level = LEVEL_PLAN;
  1192. X      where.snum = s->storbits;
  1193. X      where.pnum = s->pnumorbits;
  1194. X
  1195. X      numdest =(int)blast(Playernum,&where, &where, 0, p, x, y, Dist, 100.,
  1196. X            round_rand(log1p((double)s->mass)*2+(float)s->destruct/3.), 1);
  1197. X      sprintf(buf,"BOOM!! Ship #%d crashes on sector %d,%d with blast radius of %d.\n",
  1198. X        shipno, x, y, numdest);
  1199. X
  1200. X      for (i=1; i<=Numraces(); i++)
  1201. X        if (p->info[i-1].numsectsowned || i==Playernum)
  1202. X            notify(i, buf);
  1203. X
  1204. X     } else {
  1205. X           s->xpos = (float)x;
  1206. X         s->ypos = (float)y;
  1207. X
  1208. X         s->fuel -= fuel;
  1209. X         s->mass -= fuel * MASS_FUEL;
  1210. X         s->is_docked = 1;
  1211. X         s->whatdest = LEVEL_PLAN;    /* no destination */
  1212. X         s->deststar = s->storbits;
  1213. X         s->destpnum = s->pnumorbits;
  1214. X     }
  1215. X
  1216. X    openshdata(&land_shdata);
  1217. X         putship(land_shdata, s, shipno);
  1218. X      close_file(land_shdata);
  1219. X
  1220. X
  1221. X  if (s->whatorbits==LEVEL_UNIV)
  1222. X      deductAPs(Playernum,APcount, 0, 1);
  1223. X  else
  1224. X      deductAPs(Playernum,APcount, s->storbits, 0);
  1225. X
  1226. X
  1227. X          openpdata(&land_pdata);
  1228. X          putplanet(land_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
  1229. X              close_file(land_pdata);
  1230. X    if(numdest) {
  1231. X        opensectdata(&land_sectdata);
  1232. X          putsector(land_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
  1233. X              close_file(land_sectdata);
  1234. X        }
  1235. X
  1236. X    /* send messages to anyone there */
  1237. X          sprintf(buf,"%s #%d observed landing on sector %.0f,%.0f, planet /%s/%s.\n",
  1238. X            Shipnames[s->type], shipno, s->xpos,s->ypos,Stars[s->storbits]->name,
  1239. X            Stars[s->storbits]->pnames[s->pnumorbits]);
  1240. X
  1241. X      for (i=1; i<=Numraces(); i++)
  1242. X        if (p->info[i-1].numsectsowned && i!=Playernum)
  1243. X            notify(i, buf);
  1244. X
  1245. X        sprintf(buf,"%s #%d %s landed on planet.\n",Shipnames[s->type],
  1246. X         shipno,s->name);
  1247. X        notify(Playernum, buf);
  1248. X
  1249. X         free(sect);
  1250. X       free(p);
  1251. X    free(s);
  1252. X
  1253. X}
  1254. X
  1255. X
  1256. END_OF_FILE
  1257. if test 6431 -ne `wc -c <'server/land.c'`; then
  1258.     echo shar: \"'server/land.c'\" unpacked with wrong size!
  1259. fi
  1260. # end of 'server/land.c'
  1261. if test -f 'server/launch.c' -a "${1}" != "-c" ; then 
  1262.   echo shar: Renaming existing file \"'server/launch.c'\" to \"'server/launch.c.orig'\"
  1263.   mv -f 'server/launch.c' 'server/launch.c.orig'
  1264. fi
  1265. echo shar: Extracting \"'server/launch.c'\" \(6685 characters\)
  1266. sed "s/^X//" >'server/launch.c' <<'END_OF_FILE'
  1267. X/*
  1268. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1269. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1270. X * Restrictions in GB_copyright.h.
  1271. X *
  1272. X *  launch.c -- launch or undock a ship (also undock)
  1273. X */
  1274. X
  1275. X#include "GB_copyright.h"
  1276. X#define EXTERN extern
  1277. X#include "vars.h"
  1278. X#include "ships.h"
  1279. X#include "buffers.h"
  1280. X#include <signal.h>
  1281. X
  1282. X
  1283. Xint launch_shdata,launch_pdata,launch_stdata;
  1284. X
  1285. Xlaunch(Playernum,APcount, argn,args)
  1286. Xint Playernum;
  1287. Xint APcount;
  1288. Xint argn;
  1289. Xchar args[MAXARGS][COMMANDSIZE];
  1290. X{
  1291. Xint sh, sh2, sh3;
  1292. Xshiptype *s,*s2,*s3;
  1293. Xplanettype *p;
  1294. Xboolean planet=0;
  1295. Xint shipno, i;
  1296. Xfloat fuel;
  1297. X
  1298. Xlaunch_shdata = launch_pdata = NEUTRAL_FD;
  1299. X
  1300. X    sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  1301. X
  1302. X  openshdata(&launch_shdata);
  1303. X  if (!getship(launch_shdata, &s, shipno)) {
  1304. X      close_file(launch_shdata);
  1305. X      return;
  1306. X  }
  1307. Xclose_file(launch_shdata);
  1308. X
  1309. X
  1310. X  if (s->owner!=Playernum) {
  1311. X    DontOwnErr(Playernum,shipno);
  1312. X    free(s);
  1313. X    return;
  1314. X  }
  1315. X
  1316. X  if (!speed_rating(s)) {
  1317. X    sprintf(buf,"That ship is not designed to be launched.\n");
  1318. X        notify(Playernum, buf);
  1319. X    free(s);
  1320. X    return;
  1321. X  }
  1322. X
  1323. X
  1324. X  if (testship(Playernum,s,shipno)) {
  1325. X    free(s);
  1326. X    return;
  1327. X    }
  1328. X
  1329. X  if (!s->is_docked) {
  1330. X    sprintf(buf,"Ship #%d is not landed or docked.\n",shipno);
  1331. X        notify(Playernum, buf);
  1332. X    free(s);
  1333. X    return;
  1334. X  }
  1335. X
  1336. X  if (s->whatdest==LEVEL_PLAN && s->resource > Max_resource(s)) {
  1337. X    sprintf(buf,"Ship #%d is too overloaded to launch.\n", shipno);
  1338. X        notify(Playernum, buf);
  1339. X    free(s);
  1340. X    return;
  1341. X  }
  1342. X
  1343. X  if (s->whatdest==LEVEL_SHIP) {
  1344. X
  1345. X    sh2 = s->destshipno; 
  1346. X
  1347. X         openshdata(&launch_shdata);
  1348. X    (void)getship(launch_shdata, &s2, sh2);
  1349. X          close_file(launch_shdata);
  1350. X      if (s2->whatorbits==LEVEL_UNIV) {
  1351. X      if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) { 
  1352. X        free(s);
  1353. X        free(s2);
  1354. X        return;
  1355. X     } else
  1356. X          deductAPs(Playernum,APcount, 0, 1);
  1357. X      } else {
  1358. X      if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
  1359. X        free(s);
  1360. X        free(s2);
  1361. X        return;
  1362. X      } else
  1363. X          deductAPs(Playernum,APcount, s->storbits, 0);
  1364. X    }
  1365. X
  1366. X    if(s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER && 
  1367. X            s2->destshipno!=shipno) {   
  1368. X
  1369. X        /* fighters docked with carriers - in the sublist!*/
  1370. X        /* fix carrier linked list */
  1371. X
  1372. X    sh = s2->object.number;
  1373. X    if(!sh) {
  1374. X        notify(Playernum, "Weird error!  01\n");
  1375. X        free(s);
  1376. X        free(s2);
  1377. X        return;
  1378. X        }
  1379. X
  1380. X    if(sh == shipno) {
  1381. X        s2->object.number = s->object.number;
  1382. X        } else {
  1383. X
  1384. X            openshdata(&launch_shdata);
  1385. X            while(sh != shipno) {
  1386. X            (void)getship(launch_shdata, &s3, sh);
  1387. X            sh3 = sh;
  1388. X            sh = s3->object.number;
  1389. X            if(sh != shipno) free(s3);
  1390. X        }
  1391. X
  1392. X        s3->object.number = s->object.number; /* change pointer */
  1393. X        putship(launch_shdata, s3, sh3);
  1394. X        close_file(launch_shdata);
  1395. X        free(s3);
  1396. X        }
  1397. X
  1398. X    /* fighter is on its own */
  1399. X    s->is_docked = 0;
  1400. X    s->whatdest = LEVEL_UNIV;
  1401. X    s->whatorbits = s2->whatorbits;
  1402. X    s->object.number = 0;
  1403. X    s->object.number4 = 0;
  1404. X    s->destshipno = 0;
  1405. X    s->xpos = s2->xpos;
  1406. X    s->ypos = s2->ypos;
  1407. X    s->storbits = s2->storbits;
  1408. X    s->pnumorbits = s2->pnumorbits;
  1409. X
  1410. X    s2->mass -= s->mass; /* carrier is lighter */
  1411. X    s2->object.number4 -= 1;
  1412. X/* put fighter into the appropriate linked list (planet/star/universe).
  1413. X   it is put into the level of the carrier */
  1414. X
  1415. X    if(s2->whatorbits==LEVEL_PLAN) {
  1416. X            openpdata(&launch_pdata);
  1417. X          getplanet(launch_pdata, &p, Stars[s2->storbits]->planetpos[s2->pnumorbits]);
  1418. X            s->nextship = p->ships;
  1419. X            p->ships = shipno;    
  1420. X          putplanet(launch_pdata,p,Stars[s2->storbits]->planetpos[s2->pnumorbits]);
  1421. X          close_file(launch_pdata);
  1422. X        free(p);
  1423. X    } else if(s2->whatorbits==LEVEL_STAR) {
  1424. X          openstardata(&launch_stdata);
  1425. X        free(Stars[s2->storbits]);
  1426. X          getstar(launch_stdata, &Stars[s2->storbits],s2->storbits);
  1427. X            s->nextship = Stars[s2->storbits]->ships;
  1428. X            Stars[s2->storbits]->ships = shipno;
  1429. X          putstar(launch_stdata, Stars[s2->storbits],s2->storbits);
  1430. X        close_file(launch_stdata);
  1431. X    } else if(s2->whatorbits==LEVEL_UNIV) {
  1432. X            s->nextship = Sdata.ships;
  1433. X            Sdata.ships = shipno;
  1434. X        }
  1435. X
  1436. X    } else {
  1437. X    s->is_docked = 0;
  1438. X    s->whatdest = LEVEL_UNIV;
  1439. X    sh2 = s->destshipno;
  1440. X    s->destshipno = 0;
  1441. X    s2->is_docked = 0;
  1442. X    s2->whatdest = LEVEL_UNIV;
  1443. X    s2->destshipno = 0;
  1444. X
  1445. X        } 
  1446. X
  1447. X
  1448. X    sprintf(buf,"%s #%d undocked from %s #%d.\n", 
  1449. X        Shipnames[s->type], shipno, Shipnames[s2->type],sh2);
  1450. X        notify(Playernum, buf);
  1451. X    openshdata(&launch_shdata);
  1452. X    putship(launch_shdata, s, shipno);
  1453. X    putship(launch_shdata, s2, sh2);
  1454. X    close_file(launch_shdata);
  1455. X
  1456. X    free(s);
  1457. X    free(s2);
  1458. X
  1459. X  } else {
  1460. X
  1461. X      if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) { 
  1462. X        free(s);
  1463. X        return;
  1464. X      } else
  1465. X          deductAPs(Playernum,APcount, s->storbits, 0);
  1466. X
  1467. X  s->is_docked = 0;
  1468. X  s->whatdest = LEVEL_UNIV;    /* no destination */
  1469. X
  1470. X
  1471. X    /* adjust x,ypos to absolute coords */
  1472. X  openpdata(&launch_pdata);
  1473. X  getplanet(launch_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  1474. X  close_file(launch_pdata);
  1475. X
  1476. X  sprintf(buf,"Planet /%s/%s has gravity field of %.2f\n", Stars[s->storbits]->name,
  1477. X    Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
  1478. X        notify(Playernum, buf);
  1479. X   /* alter sector location of ship x,y to stellar coords x,y */
  1480. X  s->xpos = Stars[s->storbits]->xpos + p->xpos + 
  1481. X        (float)int_rand((int)(-DIST_TO_LAND/4),(int)(DIST_TO_LAND/4));
  1482. X  s->ypos = Stars[s->storbits]->ypos + p->ypos + 
  1483. X        (float)int_rand((int)(-DIST_TO_LAND/4),(int)(DIST_TO_LAND/4));
  1484. X
  1485. X   /* subtract fuel from ship */
  1486. X  fuel = gravity(p) * s->mass * LAUNCH_GRAV_MASS_FACTOR;
  1487. X  if (s->fuel < fuel) {
  1488. X    sprintf(buf,"Ship #%d does not have enough fuel! (%.1f)\n",shipno, fuel);
  1489. X        notify(Playernum, buf);
  1490. X    free(p);
  1491. X    free(s);
  1492. X    return;
  1493. X  }
  1494. X  s->fuel -= fuel;
  1495. X  s->mass -= fuel * MASS_FUEL;
  1496. X
  1497. X
  1498. X  if (s->type == OTYPE_CANIST)
  1499. X    s->object.number = 80;    /* canister dissapates after 80 updates */
  1500. X
  1501. X      s->notified = 0;
  1502. X    openshdata(&launch_shdata);
  1503. X      putship(launch_shdata, s, shipno);
  1504. X      close_file(launch_shdata);
  1505. X
  1506. X  if (!p->is_explored) {
  1507. X        /* not yet explored by owner; space exploration causes the
  1508. X           player to see a whole map */
  1509. X    p->is_explored = 1;
  1510. Xopenpdata(&launch_pdata);
  1511. X      putplanet(launch_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
  1512. X      close_file(launch_pdata);
  1513. X  }
  1514. X
  1515. X          sprintf(buf,"%s #%d observed launching from planet /%s/%s.\n",
  1516. X            Shipnames[s->type], shipno,Stars[s->storbits]->name,
  1517. X            Stars[s->storbits]->pnames[s->pnumorbits]);
  1518. X      for (i=1; i<=Numraces(); i++)
  1519. X        if (p->info[i-1].numsectsowned && i!=Playernum) notify(i, telegram_buf);
  1520. X
  1521. X  free(p);
  1522. X
  1523. X  sprintf(buf,"%s #%d %s launched from planet,", Shipnames[s->type], shipno, s->name);
  1524. X        notify(Playernum, buf);
  1525. X  sprintf(buf," using %.1f fuel.\n",fuel);
  1526. X         notify(Playernum, buf);
  1527. X if (s->type == OTYPE_CANIST) {
  1528. X        notify(Playernum, buf);
  1529. X    sprintf(buf, "A thick cloud of dust envelops your planet.\n");
  1530. X        notify(Playernum, buf); 
  1531. X    }
  1532. X
  1533. X  free(s);
  1534. X
  1535. X  }
  1536. X
  1537. X}
  1538. X
  1539. X
  1540. END_OF_FILE
  1541. if test 6685 -ne `wc -c <'server/launch.c'`; then
  1542.     echo shar: \"'server/launch.c'\" unpacked with wrong size!
  1543. fi
  1544. # end of 'server/launch.c'
  1545. if test -f 'server/scrap.c' -a "${1}" != "-c" ; then 
  1546.   echo shar: Renaming existing file \"'server/scrap.c'\" to \"'server/scrap.c.orig'\"
  1547.   mv -f 'server/scrap.c' 'server/scrap.c.orig'
  1548. fi
  1549. echo shar: Extracting \"'server/scrap.c'\" \(7618 characters\)
  1550. sed "s/^X//" >'server/scrap.c' <<'END_OF_FILE'
  1551. X/*
  1552. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1553. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1554. X * Restrictions in GB_copyright.h.
  1555. X *
  1556. X * scrap.c -- turn a ship to junk
  1557. X */
  1558. X
  1559. X#include "GB_copyright.h"
  1560. X#define EXTERN extern
  1561. X#include "vars.h"
  1562. X#include "ships.h"
  1563. X#include "races.h"
  1564. X#include "buffers.h"
  1565. X#include <signal.h>
  1566. X
  1567. Xint scrap_shdata, scrap_pdata,scrap_sectdata, scrap_racedata;
  1568. X
  1569. Xscrap(Playernum,APcount, argn,args)
  1570. Xint Playernum;
  1571. Xint APcount;
  1572. Xint argn;
  1573. Xchar args[MAXARGS][COMMANDSIZE];
  1574. X{
  1575. Xplanettype *planet;
  1576. Xsectortype *sect;
  1577. Xshiptype *s,*s2;
  1578. Xint i,mask,shipno,scrapval=0,destval=0,crewval=0, xtalval=0;
  1579. Xfloat fuelval=0.0;
  1580. Xracetype *Race;
  1581. X
  1582. Xscrap_shdata = scrap_pdata = NEUTRAL_FD;
  1583. X
  1584. X     sscanf(args[1] + (*args[1]=='#'),"%d", &shipno);
  1585. X
  1586. X openshdata(&scrap_shdata);
  1587. X if (!getship(scrap_shdata,&s,shipno)) {
  1588. X     close_file(scrap_shdata);
  1589. X    return;
  1590. X }
  1591. Xclose_file(scrap_shdata);
  1592. X
  1593. X if (s->owner!=Playernum || !s->is_alive) {
  1594. X    DontOwnErr(Playernum,shipno);
  1595. X    free(s);
  1596. X    return;
  1597. X }
  1598. X
  1599. X
  1600. X if (s->whatorbits==LEVEL_UNIV) {
  1601. X     if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount))
  1602. X        free(s);
  1603. X        return;
  1604. X } else if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
  1605. X        free(s);
  1606. X        return;
  1607. X        }
  1608. X
  1609. X if (s->whatorbits==LEVEL_PLAN && s->type==OTYPE_TOXWC) {
  1610. X    sprintf(buf,"WARNING: This will release %d toxin points back into the atmosphere!!\n", s->object.number);
  1611. X        notify(Playernum, buf);
  1612. X    }
  1613. X
  1614. X if ( !s->is_docked) {
  1615. X    sprintf(buf,"%s #%d is not landed or docked.\nNo resources can be reclaimed.\n",Shipnames[s->type], shipno);
  1616. X        notify(Playernum, buf);
  1617. X }
  1618. X
  1619. X if (s->whatorbits==LEVEL_PLAN) {        /* wc's release poison */
  1620. X     openpdata(&scrap_pdata);
  1621. X     getplanet(scrap_pdata, &planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
  1622. X    close_file(scrap_pdata);
  1623. X    
  1624. X   if (s->is_docked && s->whatdest==LEVEL_PLAN) {
  1625. X        opensectdata(&scrap_sectdata);
  1626. X        getsector(scrap_sectdata, §, planet->sectormappos
  1627. X         +((int)s->ypos*planet->Maxx+(int)s->xpos)*sizeof(sectortype));
  1628. X    close_file(scrap_sectdata);
  1629. X    }
  1630. X
  1631. X    }
  1632. X
  1633. X
  1634. X if (s->is_docked && s->whatdest==LEVEL_SHIP) {
  1635. X     openshdata(&scrap_shdata);
  1636. X     if (!getship(scrap_shdata, &s2, (int)s->destshipno)) {
  1637. X        close_file(scrap_shdata);
  1638. X        free(s);
  1639. X        return;
  1640. X        }
  1641. X    close_file(scrap_shdata);
  1642. X    if ( !(s2->is_docked && s2->destshipno == shipno) ) {
  1643. X        sprintf(buf,"Warning, other ship not docked..\n");
  1644. X            notify(Playernum, buf);
  1645. X        free(s);
  1646. X        free(s2);
  1647. X        return;
  1648. X    }
  1649. X } 
  1650. X
  1651. X scrapval = Cost(s) * .50 + s->resource;
  1652. X
  1653. X if (s->is_docked) {
  1654. X
  1655. X     sprintf(buf,"%s #%d:original cost: %d\n",
  1656. X        Shipnames[s->type], shipno, Cost(s));
  1657. X            notify(Playernum, buf);
  1658. X     sprintf(buf,"         scrap value%s: %d rp's.\n",
  1659. X        s->resource ? "(with stockpile) " : "", scrapval);
  1660. X            notify(Playernum, buf);
  1661. X
  1662. X     if (s->whatdest==LEVEL_SHIP && s->resource+scrapval > Max_resource(s2) 
  1663. X            && s->type!=STYPE_SHUTTLE) {
  1664. X        scrapval = Max_resource(s2) - s->resource;
  1665. X        sprintf(buf,"(There is only room for %d resources.)\n",scrapval);
  1666. X            notify(Playernum, buf);
  1667. X             }
  1668. X
  1669. X     if (s->fuel) {
  1670. X       sprintf(buf,"Fuel recovery: %.0f.\n", s->fuel);
  1671. X            notify(Playernum, buf);
  1672. X       fuelval = s->fuel;
  1673. X       if (s->whatdest == LEVEL_SHIP && s->fuel+fuelval > Max_fuel(s2)) {
  1674. X        fuelval = Max_fuel(s2) - s->fuel;
  1675. X        sprintf(buf,"(There is only room for %.2f fuel.)\n",fuelval);
  1676. X            notify(Playernum, buf);
  1677. X       }
  1678. X     } else
  1679. X       fuelval = 0.0;
  1680. X
  1681. X     if (s->destruct) {
  1682. X       sprintf(buf,"Weapons recovery: %d.\n", s->destruct);
  1683. X            notify(Playernum, buf);
  1684. X       destval = s->destruct;
  1685. X       if (s->whatdest == LEVEL_SHIP && s->destruct+destval > Max_destruct(s2)) {
  1686. X        destval = Max_destruct(s2) - s->destruct;
  1687. X        sprintf(buf,"(There is only room for %d destruct.)\n",destval);
  1688. X            notify(Playernum, buf);
  1689. X       }
  1690. X     } else
  1691. X       destval = 0;
  1692. X
  1693. X     if (s->popn) {
  1694. X       if (s->whatdest==LEVEL_PLAN && sect->owner>0 && sect->owner!=Playernum) {
  1695. X        sprintf(buf,"You don't own this sector; no crew can be recovered.\n");
  1696. X            notify(Playernum, buf);
  1697. X       } else {
  1698. X          sprintf(buf,"Population recovery: %d.\n", s->popn);
  1699. X            notify(Playernum, buf);
  1700. X          crewval = s->popn;
  1701. X          if (s->whatdest==LEVEL_SHIP && s->popn+crewval > Max_crew(s2)) {
  1702. X        crewval = Max_crew(s) - s->popn;
  1703. X        sprintf(buf,"(There is only room for %d crew.)\n",crewval);
  1704. X            notify(Playernum, buf);
  1705. X          }
  1706. X       }
  1707. X     } else
  1708. X       crewval = 0;
  1709. X
  1710. X     if (s->crystals) {
  1711. X       if (s->whatdest==LEVEL_PLAN && sect->owner>0 && sect->owner!=Playernum) {
  1712. X        sprintf(buf,"You don't own this sector; no crystals can be recovered.\n");
  1713. X            notify(Playernum, buf);
  1714. X       } else {
  1715. X          sprintf(buf,"Crystal recovery: %d.\n", s->crystals);
  1716. X            notify(Playernum, buf);
  1717. X          xtalval = s->crystals;
  1718. X          if (s->whatdest==LEVEL_SHIP && s->crystals+xtalval > Max_crystals(s2)) {
  1719. X        xtalval = Max_crystals(s) - s->crystals;
  1720. X        sprintf(buf,"(There is only room for %d crystals.)\n",xtalval);
  1721. X            notify(Playernum, buf);
  1722. X          }
  1723. X       }
  1724. X     } else
  1725. X       xtalval = 0;
  1726. X
  1727. X}
  1728. X
  1729. X
  1730. X
  1731. X if (s->whatorbits==LEVEL_UNIV)
  1732. X     deductAPs(Playernum,APcount, 0, 1);
  1733. X else
  1734. X     deductAPs(Playernum,APcount, s->storbits, 0);
  1735. X
  1736. X kill_ship(Playernum, s);
  1737. X
  1738. Xopenshdata(&scrap_shdata);
  1739. Xputship(scrap_shdata, s, shipno);
  1740. Xclose_file(scrap_shdata);
  1741. X if (s->is_docked && s->whatdest==LEVEL_SHIP) {
  1742. X     fuelval = MIN(fuelval, 1.*Max_fuel(s2) - s2->fuel);
  1743. X     destval = MIN(destval, Max_destruct(s2) - s2->destruct);
  1744. X     scrapval = MIN(scrapval, Max_resource(s2) - s2->resource);
  1745. X     crewval = MIN(crewval, Max_crew(s2) - s2->popn);
  1746. X     xtalval = MIN(xtalval, Max_crystals(s2) - s2->crystals);
  1747. X         s2->fuel += fuelval;
  1748. X    s2->destruct += destval;
  1749. X    s2->resource += scrapval;
  1750. X    s2->popn += crewval;
  1751. X    s2->crystals += xtalval;
  1752. X
  1753. Xopenracedata(&scrap_racedata);
  1754. Xgetrace(scrap_racedata, &Race, Playernum);
  1755. Xclose_file(scrap_racedata);
  1756. X    s2->mass += fuelval*MASS_FUEL + destval*MASS_DESTRUCT + scrapval*MASS_RESOURCE + crewval*Race->mass;
  1757. Xfree(Race);
  1758. X
  1759. X     s2->is_docked = 0; /* undock the surviving ship */
  1760. X     s2->whatdest = LEVEL_UNIV;
  1761. X     s2->destshipno = 0;
  1762. X     openshdata(&scrap_shdata);
  1763. X    putship(scrap_shdata, s2, s->destshipno);
  1764. X    close_file(scrap_shdata);
  1765. X    free(s2);
  1766. X    }
  1767. X
  1768. X
  1769. X
  1770. X if (s->whatorbits==LEVEL_PLAN) {
  1771. X
  1772. X     /* distribute poison over planet even if orbiting */
  1773. X   if (s->type==OTYPE_TOXWC) {
  1774. X    if (planet->conditions[TOXIC] > 100 - s->object.number)
  1775. X        planet->conditions[TOXIC] = 100;
  1776. X    else
  1777. X        planet->conditions[TOXIC] += s->object.number;
  1778. X
  1779. X    sprintf(buf,"Planetary toxin concentration is now %d.\n", 
  1780. X        planet->conditions[TOXIC]);
  1781. X        notify(Playernum, buf);
  1782. X   }
  1783. X
  1784. X   if (s->is_docked && s->whatdest==LEVEL_PLAN) {
  1785. X
  1786. X       if (sect->owner==Playernum) {
  1787. X        sect->popn += crewval;
  1788. X       } else if (sect->owner == 0) {
  1789. X        sect->owner = Playernum;
  1790. X        sect->popn += crewval;
  1791. X        planet->info[Playernum-1].numsectsowned++;
  1792. X        sprintf(buf,"Sector %.0f,%.0f Colonized.\n",s->xpos,s->ypos);
  1793. X        notify(Playernum, buf);
  1794. X       }
  1795. X     planet->info[Playernum-1].resource += scrapval;
  1796. X     planet->popn += crewval;
  1797. X     planet->info[Playernum-1].destruct += destval;
  1798. X     planet->info[Playernum-1].fuel += (int)fuelval;
  1799. X     planet->info[Playernum-1].crystals += (int)xtalval;
  1800. X
  1801. X       opensectdata(&scrap_sectdata);
  1802. X       putsector(scrap_sectdata, sect, planet->sectormappos
  1803. X         +((int)s->ypos*planet->Maxx+(int)s->xpos)*sizeof(sectortype));
  1804. X       close_file(scrap_sectdata);
  1805. X       free(sect);
  1806. X
  1807. X   }
  1808. X
  1809. X   openpdata(&scrap_pdata);
  1810. X   putplanet(scrap_pdata, planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
  1811. X   close_file(scrap_pdata);
  1812. X   free(planet);
  1813. X }
  1814. X
  1815. X
  1816. X   if (s->is_docked && s->whatdest==LEVEL_PLAN) {
  1817. X    sprintf(buf,"\nScrapped.\n");
  1818. X        notify(Playernum, buf);
  1819. X   } else {
  1820. X    sprintf(buf,"\nDestroyed.\n");
  1821. X        notify(Playernum, buf);
  1822. X        }
  1823. X
  1824. X free(s);
  1825. X}
  1826. X
  1827. X
  1828. END_OF_FILE
  1829. if test 7618 -ne `wc -c <'server/scrap.c'`; then
  1830.     echo shar: \"'server/scrap.c'\" unpacked with wrong size!
  1831. fi
  1832. # end of 'server/scrap.c'
  1833. if test -f 'server/ships.h' -a "${1}" != "-c" ; then 
  1834.   echo shar: Renaming existing file \"'server/ships.h'\" to \"'server/ships.h.orig'\"
  1835.   mv -f 'server/ships.h' 'server/ships.h.orig'
  1836. fi
  1837. echo shar: Extracting \"'server/ships.h'\" \(7935 characters\)
  1838. sed "s/^X//" >'server/ships.h' <<'END_OF_FILE'
  1839. X/*
  1840. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1841. X * smq@ucscb.ucsc.edu, mods by people in GB.c, enroll.dat.
  1842. X * Restrictions in GB.c.
  1843. X */
  1844. X
  1845. X
  1846. X#define STYPE_POD    0
  1847. X#define STYPE_SHUTTLE     1
  1848. X#define STYPE_CARRIER   2
  1849. X#define STYPE_DREADNT    3
  1850. X#define STYPE_BATTLE     4
  1851. X#define STYPE_INTCPT    5
  1852. X#define STYPE_CRUISER    6
  1853. X#define STYPE_DESTROYER 7
  1854. X#define STYPE_FIGHTER     8
  1855. X#define STYPE_EXPLORER     9
  1856. X#define STYPE_HABITAT     10
  1857. X#define STYPE_STATION    11
  1858. X#define STYPE_ASS    12
  1859. X#define STYPE_CARGO     13
  1860. X#define STYPE_TANKER     14
  1861. X#define STYPE_GOD    15
  1862. X#define STYPE_MINE    16
  1863. X#define STYPE_MIRROR    17
  1864. X
  1865. X#define OTYPE_STELE    18
  1866. X#define OTYPE_GTELE    19
  1867. X#define OTYPE_TRACT    20
  1868. X#define OTYPE_AP    21
  1869. X#define OTYPE_CANIST    22
  1870. X#define OTYPE_VN    23
  1871. X#define OTYPE_BERS    24
  1872. X#define OTYPE_GOV    25
  1873. X#define OTYPE_OMCL    26
  1874. X#define OTYPE_TOXWC    27
  1875. X#define OTYPE_PROBE    28
  1876. X#define OTYPE_GR    29
  1877. X#define OTYPE_FACTORY    30
  1878. X#define OTYPE_TERRA    31
  1879. X#define OTYPE_BERSCTLC    32
  1880. X#define OTYPE_AUTOFAC    33
  1881. X#define OTYPE_TRANSDEV    34
  1882. X#define OTYPE_REPAIR    35
  1883. X#define OTYPE_PLANDEF    36
  1884. X
  1885. X#define ABIL_CARGO     0
  1886. X#define ABIL_DESTCAP     1
  1887. X#define ABIL_GUNS     2
  1888. X#define ABIL_FUELCAP     3
  1889. X#define ABIL_TECH     4
  1890. X#define ABIL_MAXCREW     5
  1891. X#define ABIL_ARMOR     6
  1892. X#define ABIL_COST     7
  1893. X#define ABIL_JUMP     8
  1894. X#define ABIL_CANLAND    9
  1895. X#define ABIL_HASSWITCH    10
  1896. X#define ABIL_SPEED    11
  1897. X#define ABIL_DAMAGE    12
  1898. X#define ABIL_BUILD    13
  1899. X#define ABIL_CONSTRUCT    14
  1900. X#define ABIL_MOD    15
  1901. X#define ABIL_LASER    16
  1902. X#define ABIL_PROGRAMMED 17
  1903. X
  1904. X#define NUMSTYPES     (OTYPE_PLANDEF+1)
  1905. X#define NUMABILS     (ABIL_PROGRAMMED+1)
  1906. X
  1907. X#define SHIP_NAMESIZE    18
  1908. X
  1909. X
  1910. X
  1911. Xtypedef struct ship shiptype;
  1912. Xtypedef struct ship_new shiptype_new;
  1913. Xtypedef struct place placetype;
  1914. X
  1915. X
  1916. Xstruct ship {
  1917. X    float xpos,ypos;
  1918. X    float fuel,mass;
  1919. X    char name[SHIP_NAMESIZE];        /* name of ship (optional) */
  1920. X    char class[SHIP_NAMESIZE];        /* class of ship - designated by players */
  1921. X    char mission[64];            /* notes for each ship */
  1922. X    percent morale;            /* morale of the crew */
  1923. X    unsigned short command;        /* captain+staff leadership value */
  1924. X
  1925. X    int dummy1;
  1926. X
  1927. X    unsigned short destshipno;        /* destination ship # */
  1928. X    unsigned short nextship;        /* next ship in linked list */
  1929. X
  1930. X    percent armor;
  1931. X    percent guns;
  1932. X    percent size;
  1933. X
  1934. X    unsigned short max_crew;
  1935. X    unsigned short max_resource;
  1936. X    unsigned short max_destruct;
  1937. X    unsigned short max_fuel;
  1938. X    unsigned short max_speed;
  1939. X    unsigned short build_type;    /* for factories - type of ship it makes */
  1940. X    unsigned short build_cost;
  1941. X
  1942. X    int dummy2;
  1943. X    
  1944. X    float base_mass;
  1945. X    float tech;        /* technology rating */
  1946. X
  1947. X    unsigned short destruct;         /* stuff it's carrying */
  1948. X    unsigned short resource;
  1949. X    unsigned short popn;            /* crew */
  1950. X    unsigned short crystals;
  1951. X
  1952. X
  1953. X    struct a {        /* if the ship is a Space Mirror */
  1954. X        unsigned short shipno;    /* aimed at what ship */
  1955. X        char snum;        /* aimed at what star */
  1956. X        percent intensity;        /* intensity of aiming */
  1957. X        unsigned pnum : BITS_MAXPLANETS;  /* aimed at what planet */
  1958. X        unsigned level : 2;    /* aimed at what level */
  1959. X    } aimed_at;
  1960. X    
  1961. X    struct o2 {
  1962. X        short number;    /* for misc functions */
  1963. X        short number2;    /* again */
  1964. X        short number3;
  1965. X        short number4;  /* again */
  1966. X    } object;
  1967. X    
  1968. X    struct nv {
  1969. X        unsigned on : 1;    /* toggles navigate mode */
  1970. X        unsigned speed : 4; /* speed for navigate command */
  1971. X        unsigned turns : 15;/* number turns left in maneuver */
  1972. X        unsigned bearing : 9; /* course */
  1973. X        unsigned dummy : 3;
  1974. X        } navigate;
  1975. X    
  1976. X    struct prot {
  1977. X        float maxrng;           /* maximum range for autoshoot */
  1978. X        unsigned on     :  1; /* toggle on/off */
  1979. X        unsigned planet  :  1; /* planet defender */
  1980. X         unsigned self     :  1; /* retaliate if attacked */
  1981. X         unsigned evade     :  1; /* evasive action */
  1982. X         unsigned ship     : 14; /* ship it is protecting */
  1983. X        unsigned dummy     :  6;
  1984. X        } protect;
  1985. X
  1986. X        struct hd {
  1987. X            unsigned int charge : 7;
  1988. X            unsigned ready : 1;
  1989. X            unsigned on : 1;
  1990. X            unsigned has : 1;
  1991. X            unsigned mounted : 1;    /* has crystal mounted */
  1992. X        unsigned dummy : 5;
  1993. X        } hyper_drive;
  1994. X
  1995. X
  1996. X    unsigned owner : BITS_MAXPLAYERS;    /* owner of ship */
  1997. X    char storbits;        /* what star # orbits */
  1998. X    char deststar;        /* destination star */
  1999. X    unsigned destpnum : BITS_MAXPLANETS;    /* destination planet */
  2000. X    unsigned pnumorbits : BITS_MAXPLANETS;    /* # of planet if orbiting */
  2001. X    unsigned whatdest : 2;    /* where going (same as Dir) */
  2002. X    unsigned whatorbits : 2;    /* where orbited (same as Dir) */
  2003. X
  2004. X    unsigned damage : 7;        /* amt of damage */
  2005. X    unsigned rad : 7;            /* radiation level */
  2006. X    unsigned short retaliate;
  2007. X    unsigned short laser;
  2008. X    
  2009. X    unsigned type : 6;        /* what type ship is */
  2010. X    unsigned active: 1;            /* tells whether the ship is active */
  2011. X    unsigned is_alive : 1;    /* 1 bit: ship is alive */
  2012. X    unsigned mode : 1;
  2013. X    unsigned bombard : 1;    /* bombard planet we're orbiting */
  2014. X    
  2015. X    unsigned speed : 4;        /* what speed to travel at 0-9 */
  2016. X    unsigned is_cloaked : 1;    /* 1 bit: is cloaked ship */
  2017. X    unsigned is_sheep : 1;    /* 1 bit: is under influence of mind control */
  2018. X    unsigned is_docked : 1;    /* 1 bit: is landed on a planet or docked */
  2019. X    unsigned notified : 1;     /* 1bit: has been notified of something */
  2020. X    unsigned is_examined : 1;    /* 1 bit: has been examined */
  2021. X    unsigned on : 1;        /* on or off */
  2022. X    unsigned short fire_laser;    /* retaliation strength for lasers */
  2023. X    unsigned dummy4 : 1;
  2024. X};
  2025. X
  2026. X
  2027. Xstruct place {        /* used in function return for finding place */
  2028. X    char snum;
  2029. X    char pnum;
  2030. X    short shipno;
  2031. X    shiptype *shipptr;
  2032. X    unsigned level : 2;    /* .level: same as Dir */
  2033. X    unsigned err : 1;        /* if error */
  2034. X    unsigned dummy : 13;
  2035. X};
  2036. X
  2037. X /* whether ship is an object or not */
  2038. X#define is_object(s) ((s)->type > STYPE_MIRROR)
  2039. X
  2040. X /* can takeoff & land, is mobile, etc. */
  2041. X#define speed_rating(s) ((s)->max_speed)
  2042. X
  2043. X /* has an on/off switch */
  2044. X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH])
  2045. X
  2046. X /* can bombard planets */
  2047. X#define can_bombard(s) \
  2048. X    (Shipdata[(s)->type][ABIL_GUNS] && ((s)->type != STYPE_MINE))
  2049. X
  2050. X/* can navigate */
  2051. X#define can_navigate(s) (Shipdata[(s)->type][ABIL_SPEED] > 0 && (s)->type != OTYPE_TERRA && (s)->type != OTYPE_VN)
  2052. X
  2053. X /* can aim at things. */
  2054. X#define can_aim(s) ((s)->type>=STYPE_MIRROR && (s)->type<=OTYPE_TRACT)
  2055. X
  2056. X /* macro for killing a ship.  !notified means we have not yet written it
  2057. X    to the dead_ship file.  */
  2058. X/* macros to get ship stats */
  2059. X#define Armor(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_ARMOR] : (s)->armor)
  2060. X#define Guns(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_GUNS] : (s)->guns)
  2061. X#define Laser(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_LASER] : (s)->laser)
  2062. X#define Max_crew(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_MAXCREW] : (s)->max_crew)
  2063. X#define Max_resource(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_CARGO] : (s)->max_resource)
  2064. X#define Max_fuel(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_FUELCAP] : (s)->max_fuel)
  2065. X#define Max_destruct(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_DESTCAP] : (s)->max_destruct)
  2066. X#define Max_speed(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_SPEED] : (s)->max_speed)
  2067. X#define Max_crystals(s) (15)
  2068. X#define Cost(s) ( ((s)->type==OTYPE_FACTORY) ? 2*(s)->build_cost*(s)->on + Shipdata[(s)->type][ABIL_COST ] : (s)->build_cost)
  2069. X#define Mass(s) ( ((s)->type==OTYPE_FACTORY) ? 100.0 : (s)->base_mass)
  2070. X#define Sight(s) ( ((s)->type==OTYPE_PROBE) || (s)->popn)
  2071. X#define Retaliate(s) ( (s)->retaliate)
  2072. X#define Size(s) ( ((s)->type==OTYPE_FACTORY) ? ship_size(s) : (s)->size)
  2073. X#define Repair(s) ( ((s)->type==OTYPE_FACTORY) ? (s)->on : Max_crew(s))
  2074. X
  2075. Xextern placetype Getplace();
  2076. Xextern char *Dispplace(),*Dispshiporbits(),*prin_ship_orbits(),
  2077. X    *prin_aimed_at(), *prin_ship_dest();
  2078. Xextern int Shipdata[NUMSTYPES][NUMABILS];
  2079. Xextern char Shipltrs[];
  2080. Xextern char *Shipnames[];
  2081. Xextern float tele_range(), gun_range(), getmass();
  2082. X
  2083. XEXTERN shiptype **ships;
  2084. XEXTERN shiptype *shipptr;
  2085. X
  2086. END_OF_FILE
  2087. if test 7935 -ne `wc -c <'server/ships.h'`; then
  2088.     echo shar: \"'server/ships.h'\" unpacked with wrong size!
  2089. fi
  2090. # end of 'server/ships.h'
  2091. echo shar: End of archive 8 \(of 9\).
  2092. cp /dev/null ark8isdone
  2093. MISSING=""
  2094. for I in 1 2 3 4 5 6 7 8 9 ; do
  2095.     if test ! -f ark${I}isdone ; then
  2096.     MISSING="${MISSING} ${I}"
  2097.     fi
  2098. done
  2099. if test "${MISSING}" = "" ; then
  2100.     echo You have unpacked all 9 archives.
  2101.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2102. else
  2103.     echo You still need to unpack the following archives:
  2104.     echo "        " ${MISSING}
  2105. fi
  2106. ##  End of shell archive.
  2107. exit 0
  2108.